<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>员工列表</title>
    <!-- 引入Bootstrap CSS -->
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
    <h1 class="text-center mb-4">员工列表</h1>
    <table class="table table-bordered table-hover">
        <thead class="thead-light">
        <tr>
            <th>编号</th> <!-- 修改表头为“编号” -->
            <th>姓名</th>
            <th>薪资</th>
            <th>生日</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="employee, stat : ${employees}">
            <!-- 使用 stat.index + 1 生成从1开始的编号 -->
            <td th:text="${stat.index + 1}"></td>
            <td th:text="${employee.name}"></td>
            <td th:text="${'￥' + #numbers.formatDecimal(employee.salary, 1, 2)}"></td>
            <td th:text="${#temporals.format(employee.birthday, 'yyyy-MM-dd')}"></td>
            <td>
                <a th:href="@{/employee/detail/{id}(id=${employee.id})}" class="btn btn-info btn-sm">详情</a>
                <a th:href="@{/employee/edit/{id}(id=${employee.id})}" class="btn btn-warning btn-sm">编辑</a>
                <form th:action="@{/employee/delete/{id}(id=${employee.id})}" method="post" th:id="'deleteForm_' + ${employee.id}" style="display:inline;">
                    <button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('确定要删除该员工吗？')">删除</button>
                </form>
            </td>
        </tr>
        </tbody>
    </table>
    <div class="text-center mt-4">
        <a th:href="@{/employee/add}" class="btn btn-primary">添加员工</a>
    </div>
</div>
<!-- 引入Bootstrap JS（可选） -->
<script src="/js/bootstrap.bundle.min.js"></script>
</body>
</html>